import request from '@/utils/request'

// 查询模型类列表
export const getModelClassListApi = (id) =>
  request.get(`/core/vom/model/design/class/list?domainId=${id}`)

// 查询父类下拉框
export const getParentListApi = (id) =>
  request.get(`/core/vom/model/design/class/parent/combo-items?domainId=${id}`)

// 创建模型类
export const addModelClassApi = (data) =>
  request.post('/core/vom/model/design/class', data, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })

// 删除模型类
export const delModelClassApi = (id) =>
  request.post(`/core/vom/model/design/class/delete?classId=${id}`, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })

// 上移模型类
export const upClassApi = (data) =>
  request.post('/core/vom/model/design/class/move-up', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 下移模型类
export const downClassApi = (data) =>
  request.post('/core/vom/model/design/class/move-down', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询模型类信息
export const getClassDataApi = (id) =>
  request.get(`/core/vom/model/design/class?classId=${id}`)

// 修改模型类
export const editClassApi = (data) =>
  request.post('/core/vom/model/design/class/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// -----------------类属性维护-------------------

// 查询属性分组下拉框列表
export const getGroupSelectApi = (id) =>
  request.get(
    `/core/vom/model/design/property/group/combo-items?classId=${id}`
  )

// 查询类属性列表
export const getClassListApi = (data) =>
  request.get('/core/vom/model/design/property/list', { params: data })

// 查询属性类型字典下拉框列表
export const getPropTypeListApi = () =>
  request.get('/core/dictionary/combo-item/list?dictType=PropType')

// 创建类属性
export const addClassPropertyApi = (data) =>
  request.post('/core/vom/model/design/property', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 修改类属性
export const editClassPropertyApi = (data) =>
  request.post('/core/vom/model/design/property/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 删除类属性
export const delPClassropertyApi = (id) =>
  request.post(`/core/vom/model/design/property/delete?classPropertyId=${id}`, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })

// 获取模型域顶层域列表
export const getRootDomainListApi = (data) =>
  request.get('/core/vom/model/design/root-device-domain/list', data)

// 查询类属性基本信息
export const getClassPropertApi = (id) =>
  request.get(`/core/vom/model/design/property?classPropertyId=${id}`)

// 上移类属性
export const upClassPropertApi = (data) =>
  request.post('/core/vom/model/design/property/move-up', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 下移类属性
export const downClassPropertApi = (data) =>
  request.post('/core/vom/model/design/property/move-down', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询回收站类属性列表
export const getUnusedPropertApi = (id) =>
  request.get(`/core/vom/model/design/property/unused/list?classId=${id}`)

// 查询可继承类属性列表
export const getExtendPropertApi = (id) =>
  request.get(`/core/vom/model/design/property/extend/list?classId=${id}`)

// 启用类属性
export const enablePropertApi = (data) =>
  request.post('/core/vom/model/design/property/enable', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 继承类属性
export const extendPropertApi = (data) =>
  request.post('/core/vom/model/design/property/extend', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询自定义属性分组列表
export const getGroupListApi = (id) =>
  request.get(`/core/vom/model/design/property/group/list?classId=${id}`)

// 新增属性分组
export const addGroupListApi = (data) =>
  request.post('/core/vom/model/design/property/group', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询属性分组基本信息
export const getGroupDataApi = (id) =>
  request.get(`/core/vom/model/design/property/group?groupId=${id}`)

// 修改属性分组
export const editGroupListApi = (data) =>
  request.post('/core/vom/model/design/property/group/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 删除属性分组
export const delGroupListApi = (id) =>
  request.post(`/core/vom/model/design/property/group/delete?groupId=${id}`, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })

// 上移属性分组
export const upGroupApi = (data) =>
  request.post('/core/vom/model/design/property/group/move-up', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 下移属性分组
export const downGroupApi = (data) =>
  request.post('/core/vom/model/design/property/group/move-down', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// -----------------储存表维护-------------------

// 查询表模型基本信息
export const getTableDataApi = (id) =>
  request.get(`/core/vom/model/design/table?tableId=${id}`)

// 查询数据库下拉框列表
export const getDatabaseListApi = (id) =>
  request.get('/core/vom/model/design/table/database/combo-items')

// 创建表模型
export const addTableApi = (data) =>
  request.post('/core/vom/model/design/table', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询表字段列表
export const getTableListApi = (id) =>
  request.get(`/core/vom/model/design/table/field/list?tableId=${id}`)

// 查询待同步表字段列表
export const getSyncListApi = (id) =>
  request.get(`/core/vom/model/design/table/field/sync-list?tableId=${id}`)

// 查询表模型建表语句
export const getCreateSqlApi = (id) =>
  request.get(`/core/vom/model/design/table/create-sql?tableId=${id}`)

// 同步表字段
export const syncTableApi = (data) =>
  request.post('/core/vom/model/design/table/field/sync', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 修改储存表
export const editTableApi = (data) =>
  request.post('/core/vom/model/design/table/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 删除储存表
export const delTableApi = (id) =>
  request.post(`/core/vom/model/design/table/delete?tableId=${id}`, {
    headers: { 'Content-Type': 'multipart/form-data' }
  })

// 查询表字段基本信息
export const getFieldDataApi = (id) =>
  request.get(`/core/vom/model/design/table/field?fieldId=${id}`)

// 修改表字段
export const editFieldApi = (data) =>
  request.post('/core/vom/model/design/table/field/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 上移表字段
export const upFieldApi = (data) =>
  request.post('/core/vom/model/design/table/field/move-up', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 下移表字段
export const downFieldApi = (data) =>
  request.post('/core/vom/model/design/table/field/move-down', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// -----------------类关系维护-------------------

// 查询上级类关系列表
export const getUpRelationApi = (id) =>
  request.get(`/core/vom/model/design/from-relation/list?classId=${id}`)

// 查询下级类关系列表
export const getDownRelationApi = (id) =>
  request.get(`/core/vom/model/design/to-relation/list?classId=${id}`)

// 查询可新增上级关系类列表
export const getAddUpRelationApi = (id, text) =>
  request.get(`/core/vom/model/design/from-relation/create-class/list?classId=${id}&&filter=${text}`)

// 查询可新增上级关系类列表
export const getAddDownRelationApi = (id, text) =>
  request.get(`/core/vom/model/design/to-relation/create-class/list?classId=${id}&&filter=${text}`)

// 批量创建上级类关系
export const addUpRelationApi = (data) =>
  request.post('/core/vom/model/design/from-relation', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 批量创建下级类关系
export const addDownRelationApi = (data) =>
  request.post('/core/vom/model/design/to-relation', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 删除类关系
export const delRelationApi = (data) =>
  request.post('/core/vom/model/design/relation/delete', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询表索引列表
export const getIndexListApi = (id) =>
  request.get(`/core/vom/model/design/table/index/list?tableId=${id}`)

// 删除表索引
export const delIndexApi = (data) =>
  request.post('/core/vom/model/design/table/index/delete', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 查询表索引信息
export const getIndexDataApi = (id) =>
  request.get(`/core/vom/model/design/table/index?indexId=${id}`)

// 创建表索引
export const addIndexApi = (data) =>
  request.post('/core/vom/model/design/table/index', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })

// 修改表索引
export const editIndexApi = (data) =>
  request.post('/core/vom/model/design/table/index/put', data, {
    headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
  })
